package com.example.animationex;


import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.view.Menu;
import android.view.MenuItem;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;

public class MainActivity extends Activity {
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
		
		
		// XML 파일(main.xml)에서 옵션 메뉴의 서브 메뉴를 추가했다능~~~
		//
		// p.206~207 참고
	}

	
	
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {

		ImageView i = (ImageView)findViewById(R.id.imageView1);
		Animation an;
		
		Intent intent = null;
		
		int id = item.getItemId();
		
		switch(id) {
		case R.id.alpha :
			 
			an = AnimationUtils.loadAnimation(this, R.anim.alpha);
			i.startAnimation(an);
			
			// setContentView(R.anim.alpha);
            return true;
		case R.id.scale :
			
			an = AnimationUtils.loadAnimation(this, R.anim.scale);
			i.startAnimation(an);
			
            return true;
		case R.id.set :

			an = AnimationUtils.loadAnimation(this, R.anim.set);
			i.startAnimation(an);
			
            return true;
		case R.id.drawable_ani :
			
			// setContentView(R.layout.activity_drawable_ani);
			
			intent = new Intent(this, DrawableAniActivity.class);
			startActivity(intent);
			
			return true;
            
		case R.id.surface_view :
			
			intent = new Intent(this, PingPongActivity.class);
			startActivity(intent);
			
            return true;
            
        default:
        	return super.onOptionsItemSelected(item);
		}
	
	}

}
